<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/v2/console/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	    <meta content="width=device-width, minimum-scale=1,initial-scale=1, maximum-scale=1, user-scalable=1" id="viewport" name="viewport" />
	    <meta content="yes" name="apple-mobile-web-app-capable" />
	    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<title>校咖要闻</title>
	</head>
	<link rel="stylesheet" href="/sftj-offical-site/v2/news/css/style.css" />
	<link rel="stylesheet" href="/sftj-offical-site/v2/news/iconfont/iconfont.css" />
	<body>
		<!-- <div class="top">
			<span class="iconfont icon-u-arrow3-left"></span>
			<span>校咖头条</span>
			<span class="iconfont icon-ren"></span>
		</div> -->
		<div id="wrapper">
			<div id="scroller">
				<ul id="list">
			
				</ul>
		       <div id="pullUp" class="">  
                 <div class="pullUpLabel">加载更多</div>  
              </div> 
			</div>
		</div>
		
		
	</body>
	<script type="text/javascript" src="/sftj-offical-site/v2/news/js/jquery-1.6.2.min.js" ></script>
	<script type="text/javascript" src="/sftj-offical-site/v2/news/js/iscroll.probe.min.js" ></script>
	<script>
	load();
	   //开关作用就是在第一次加载时让他去主动加载一次，第一次拿不到this.y和this.maxScrollY的值
	   var onOff = true;
	   var currentPage = 0;
	   /* var flag = true; */
	   function load () {
	   	//上来执行一次，为了初始的时候页面有数据
	   	pullUpAction()
      var myScroll,  
          pullUp = $("#pullUp"),  
          pullUpLabel = $(".pullUpLabel"),  
          container = $('#list'),  
          loadingStep = 0;//加载状态0默认，1显示加载状态，2执行加载数据，只有当为0时才能再次加载，这是防止过快拉动刷新
          pullUp.hide()
          myScroll = new IScroll("#wrapper", {  
              scrollbars: false,  
              mouseWheel: false,  
              interactiveScrollbars: true,  
              shrinkScrollbars: 'scale',  
              fadeScrollbars: true,  
              scrollY:true,  
              probeType: 2,  
              bindToWrapper:true,
              click:true
          });  
          myScroll.on("scroll",function(){ 
                  if(loadingStep == 0 ){
                  	//加载不出来就是因为第一次this.y和this.maxScrollY的值，所以第一次无条件加载，这样就能正确的拿到这两个变量的值
                     if(this.y < (this.maxScrollY - 14)||onOff){//上拉加载更多
                     	
                     	onOff = false
                      pullUp.addClass("refresh").show();  
                      pullUpLabel.text("正在载入");  
                      loadingStep = 1;  
                      pullUpAction();  
                  }  
              }  
          }); 
      function pullUpAction(){
    	  /* if(flag){ */
    		 /*  flag = false; */
	          setTimeout(function(){  
	         	$.ajax({
	          		url:"${path}/web/newsList.html",
	          		type:"post",
	          		data : {nodeId:1483079600009003,start:currentPage*10},
	          		success:function(data){
	          				var str="",j;
		          			for(var i=0;i<data.list.length;i++){
		          				var img = data.list[i].picLink;
		          				var top = data.list[i].isTop;
		          				if(img!=""&&top==1){//img ,top  有图片置顶
		          					/* for (j = 0; j < 5; j++) { */  
						                   str += '<li class="content">'+
						                            '<a href="${path}/web/newsDetail.html?id='+data.list[i].articleId+'">'+
													'<img src='+data.imgPreUrl+''+img+' />'+
													'<div class="right_content">'+
														'<p>'+data.list[i].title+'</p>'+
														'<div class="text">'+
															'<span class="iconfont icon-shizhong"></span>'+
															'<span>'+data.list[i].pubTime+'</span>'+
															/* '<span>12:30</span>'+ */
															'<span class="iconfont icon-yanjing"></span>'+
															'<span>'+data.list[i].readCount+'</span>'+
															 '<div>置顶</div>'+
														'</div>'+
													'</div>'+
													'</a>'+
												'</li>'
						                /* } */  
		          				}else if(img!=""&&top==0){//img 有图片不置顶
		          						str +='<li class="content">'+
		          						       '<a href="${path}/web/newsDetail.html?id='+data.list[i].articleId+'">'+
													'<img src='+data.imgPreUrl+''+img+' />'+
													'<div class="right_content">'+
														'<p>'+data.list[i].title+'</p>'+
														'<div class="text">'+
															'<span class="iconfont icon-shizhong"></span>'+
															'<span>'+data.list[i].pubTime+'</span>'+
															/* '<span>12:30</span>'+ */
															'<span class="iconfont icon-yanjing"></span>'+
															'<span>'+data.list[i].readCount+'</span>'+
														'</div>'+
													'</div>'+
													'</a>'+
												'</li>'
		         			}else if(top==0){//没图片不置顶
		         					str+='<li class="content">'+
		         					            '<a href="${path}/web/newsDetail.html?id='+data.list[i].articleId+'">'+
													'<div class="right1_content">'+
														'<p>'+data.list[i].title+'</p>'+
														'<div class="text">'+
															'<span class="iconfont icon-shizhong"></span>'+
															'<span>'+data.list[i].pubTime+'</span>'+
															/* '<span>12:30</span>'+ */
															'<span class="iconfont icon-yanjing"></span>'+
															'<span>'+data.list[i].readCount+'</span>'+
														'</div>'+
													'</div>'+
													'</a>'+
												'</li>'
		         			}else{
			         				str+='<li class="content">'+
							            '<a href="${path}/web/newsDetail.html?id='+data.list[i].articleId+'">'+
										'<div class="right1_content">'+
											'<p>'+data.list[i].title+'</p>'+
											'<div class="text">'+
												'<span class="iconfont icon-shizhong"></span>'+
												'<span>'+data.list[i].pubTime+'</span>'+
												/* '<span>12:30</span>'+ */
												'<span class="iconfont icon-yanjing"></span>'+
												'<span>'+data.list[i].readCount+'</span>'+
												/* '<div>'+data[i].content+'</div>'+ */
												'<div>置顶</div>'+
											'</div>'+
										'</div>'+
										'</a>'+
									'</li>'
		         			}
		          			
		         		}
	          			container.append(str);  
	          			currentPage = data.currentPage;
	          			/* flag=true; */
					}
	
	          	})
	//            var li, i;  
	              
	            
	              pullUp.attr('class','').hide();  
	              myScroll.refresh();  
	              loadingStep = 0;  
	          },500);  
	      }  
	
	      }    
/*  	  }
 */     
	</script>
</html>
